<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title value='watch_history_frm'>观看历史</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/main.css" />

    <style>
    .back1 {
        /*width: 13px !important;
        height: 21px !important;
        margin-top: 11px;
        margin-left: 15px;*/
        width: 15px !important;
        height: 25px !important;
        margin-top: 12px;
        margin-left: 15px;
    }
    /*.back1 {
      width: 10px !important;
      height: 16px !important;
      margin-top: 15px;
      margin-left: 15px;
    }*/
    .button{
    background-color:#000;
    background-color:rgba(0,0,0,0);
    margin: 0px;
    border: 0px;
    line-height: 2.25rem;
    height: 2.25rem;
  }

    </style>
</head>

<body>
    <header class="aui-bar aui-bar-nav" id="aui-header" >
        <div class="aui-pull-left" onclick="closeWin()">
            <img src="../image/login/back.png" class="back1" alt="">
        </div>
        <div class="aui-title">观看历史</div>
        <button class="aui-pull-right button" style="font-size:13px;margin-right:17px" onclick="edit()" v-if="editflag">管理</button>
        <button class="aui-pull-right button" style="font-size:13px;margin-right:17px" v-if="!editflag && !cancelcollectflag" onclick="finish()">完成</button>
        <button class="aui-pull-right button" style="font-size:13px;margin-right:17px" v-if="!editflag && cancelcollectflag" disabled onclick="finish()">完成</button>
    </header>
     <footer></footer>
</body>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/win.js"></script>
<script type="text/javascript" src="../script/config.js"></script>
<script type="text/javascript" src="../script/rest.js"></script>
<script type="text/javascript" src="../script/vue.2.5.js"></script>
<script type="text/javascript" src="../script/zepto.js"></script>
<script type="text/javascript" src="../script/faskclick.js"></script>
<script type="text/javascript">
var vm, uid;
apiready = function() {
    uid = $api.getStorage('uid');
    api.parseTapmode();
    var header = $api.dom('header'); // 获取 header 标签元素
    var footer = $api.dom('footer'); // 获取 footer 标签元素
    var headerH = $api.fixStatusBar(header);
    var footerH = $api.fixTabBar(footer);
    if ('addEventListener' in document) {
        document.addEventListener('DOMContentLoaded', function() {
            FastClick.attach(document.body);
        }, false);
    }
    api.openFrame({
        name: 'watch_history_frm',
        url: 'watch_history_frm.html',
        bounces: false,
        rect: {
            marginTop: headerH, // main页面距离win顶部的高度
            marginBottom: footerH, // main页面距离win底部的高度
            w: 'auto',
            h: api.winHeight - headerH-footerH
        },
    })
    vm = new Vue({
        el: '#aui-header',
        data: {
            editflag: true,
            cancelcollectflag:false

            // iskong: true,

        },
        created: function() {
            var _this = this;
            _this.init();
        },
        methods: {
            init: function() {
                var _this = this;
                api.addEventListener({
                    name: 'clickcancelhistory'
                }, function(ret, err) {
                  _this.cancelcollectflag=true;
                });

                api.addEventListener({
                    name: 'clickcancelhistory1'
                }, function(ret, err) {
                  _this.cancelcollectflag=false;
                });
                // if(uid){
                //   new rest().get('getVideoUserHistory').datae({
                //       uid: uid
                //   }).success(function(res) {
                //       if (res.flag == 1) {
                //           if (res.msg.length == 0) {
                //               _this.iskong = true;
                //           } else {
                //               _this.iskong = false;
                //           }
                //       }
                //       console.log(JSON.stringify(res))
                //   }).error(function(err) {
                //       console.log(JSON.stringify(err))
                //   }).run()
                // }else{
                //   if($api.getStorage('histortlist')){
                //       _this.iskong = false;
                //   }else{
                //     _this.iskong = true;
                //   }
                // }
            },

        }
    })
    api.addEventListener({
        name: 'delevideohistory'
    }, function(ret, err) {
        // vm.editflag = true
        vm.init()
    });

};

function edit() {
    api.sendEvent({
        name: 'editwatchhistory',
        extra: {
            edit: 'bianji',
        }
    });
    vm.editflag = false
}

function finish() {
    api.sendEvent({
        name: 'editwatchhistory',
        extra: {
            edit: 'cancle',
        }
    });
    vm.editflag = true
}

function closeWin() {
    if (vm.editflag == false) {
        finish()
    } else {
        api.closeWin();

    }
}
</script>

</html>
